package com.wnhz.work.jy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.wnhz.work.jy.R;
import com.wnhz.work.jy.bean.HomeFragment2Bean;

import java.util.List;

/**
 * Created by d on 2016/10/8.
 */
public class HomeFragment2Adapter extends BaseAdapter {

    private Context context;
    private List<HomeFragment2Bean> lists;
    private View.OnClickListener listener;

    public HomeFragment2Adapter(Context context, List<HomeFragment2Bean> lists, View.OnClickListener listener) {
        this.context = context;
        this.lists = lists;
        this.listener = listener;
    }

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public List<HomeFragment2Bean> getLists() {
        return lists;
    }

    public void setLists(List<HomeFragment2Bean> lists) {
        this.lists = lists;
    }

    @Override
    public int getCount() {
        return lists.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        MyHolder holder;
        if(view == null){
            view = LayoutInflater.from(context).inflate(R.layout.homefragment2_listview_item,null);
            holder = new MyHolder();
            holder.time = (TextView) view.findViewById(R.id.time);
            holder.yield_tv = (TextView) view.findViewById(R.id.yield_tv);
            holder.roduct_deadline_tv = (TextView) view.findViewById(R.id.roduct_deadline_tv);
            holder.btn = view.findViewById(R.id.btn);
            view.setTag(holder);
        }
        holder = (MyHolder) view.getTag();
        holder.btn.setOnClickListener(listener);

        return view;
    }

    private class MyHolder{

        TextView time;
        TextView yield_tv;//年化收益
        TextView roduct_deadline_tv;//产品期限
        View btn;
    }
}
